<?php
session_start();
if(!isset($_SESSION['last_key']) || $_SESSION['last_key'] == NULL) {
  // user does NOT login 
  include_once('config.php');
  include_once('weibooauth.php');
  $o = new WeiboOAuth(WB_AKEY , WB_SKEY);
  $keys = $o->getRequestToken();
  $aurl = $o->getAuthorizeURL( $keys['oauth_token'] ,false , $_SERVER['SCRIPT_URI'].'callback.php');
  $_SESSION['keys'] = $keys;
  header('Location: '.$aurl) ;
  return;
}
?><html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Weibo Shell - wbsh</title>
<link rel="stylesheet" href="main.css" type="text/css" /> 
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="main.js"></script>
</head>
<body onload="page_loaded()">
<div id="output">
<div id="wbsh_info">
<span class="less">WeiboShell wbsh.sinaapp.com beta</span><br>
<span class="info">Welcome to wbsh.sinaapp.org - the unofficial weibo shell.</span><br>
This weibo-interface behaves similar to a unix-shell.<br>
You type commands and the results are shown on this page.<br>
Powered by <a href="http://jquery.com/" target="_blank">jQuery</a> & <a href="http://sae.sina.com.cn" target="_blank">SAE</a>, 
<a href="http://code.google.com/p/wbsh/" target="_blank">open source</a> under GPL V3,
written by <a href="http://www.qiwen.name" target="_blank">Wen Qi</a> (<a href="http://weibo.com/cnqiwen" target="_blank">@cnqiwen</a>)<br>
Enter <span class="info">help</span> or <span class="info">h</span> for a list of commands.<br>
</div>
</div>
<div id="input">
<table class="inputtable"><tbody>
<tr>
<td><div id="prompt" class="less">@weibo.com&gt;&nbsp;</div></td>
<td class="inputtd"><input id="inputfield" type="text" class="cmdline" autocomplete="off" value="" style="background-color: rgb(255,255,255); color:rgb(0,0,0);"/>
</td>
</tr>
</tbody></table>
</div>
<br><br>
</body>
</html>